﻿using System.ComponentModel;
using Microsoft.Practices.Prism.Interactivity;
using Microsoft.Practices.Prism.UnityExtensions;
using System.Collections.ObjectModel;
using Module.Model;
using Microsoft.Practices.Prism.Commands;
using System.Windows;
using System;
using System.ComponentModel.Design;

namespace Module.ViewModel
{
    public class StepViewModel : INotifyPropertyChanged, ISequencedObject
    {
        private Step _step { get; set; }        

        public StepViewModel()
        {
        }

        public StepViewModel(Step step)
        {
            _step = step;
        }

        public int SequenceNumber
        {
            get
            {
                return _step.Number;
            }
            set
            {
                if (_step == null)
                {
                    _step = new Step();
                }
                _step.Number = value;
                NotifyPropertyChanged("SequenceNumber");
            }
        }

        public string Name
        {
            get
            {
                return _step.Name;
            }
            set
            {
                if (_step == null)
                {
                    _step = new Step();
                }
                _step.Name = value;
                NotifyPropertyChanged("Name");
            }
        }

        public TriggerOptions Trigger
        {
            get
            {
                return _step.Trigger;
            }
            set
            {
                if (_step == null)
                {
                    _step = new Step();
                }
                _step.Trigger = value;
                NotifyPropertyChanged("Trigger");
            }
        }

        public Array Triggers 
        {
            get
            {
                return Enum.GetValues(typeof(TriggerOptions));
            }
        }

        public string Error
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public string this[string propertyname]
        {
            get
            {
                if (propertyname == "Trigger")
                {
                    string a = Trigger.ToString();   
                }
                return null;
            }
        }
        
        #region NotifyPropertyChanged Member
        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
        #endregion NotifyPropertyChanged Member
    }
}
